/*
 * Title:        CloudScheduler Toolkit
 * Description:  a Toolkit for Modeling and Simulation of Job Scheduling and Resource Provisioning in Cloud System
 * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html
 * Author:       Fuhui Wu
 *
 * Copyright (c) 2013-2014, The National University of Defense Technology, China
 */

package org.nudt.jCloud.example.basic;

import org.nudt.jCloud.fileSystem.BalanceStorer;
import org.nudt.jCloud.fileSystem.FileSystem;
import org.nudt.jCloud.fileSystem.FileSystemGenerator;
import org.nudt.jCloud.infrastructure.HomegeneousCluster;
import org.nudt.jCloud.infrastructure.SlotType;
import org.nudt.jCloud.jobScheduler.AFCFSScheduler;
import org.nudt.jCloud.resourceManager.GeneralShareStateRM;
import org.nudt.jCloud.resourceManager.ResManager;
import org.nudt.jCloud.resourceScaler.ResourceScaler;
import org.nudt.jCloud.resourceScaler.ThresholdScaler;
import org.nudt.jCloud.simulation.CloudSchedSIM;
import org.nudt.jCloud.simulation.SIMTag;
import org.nudt.jCloud.simulation.User;
import org.nudt.jCloud.simulation.UserBroker;
import org.nudt.jCloud.workload.BatchWLfromFileGen;
import org.nudt.jCloud.workload.Workload;
import org.nudt.jCloud.workload.WorkloadGenerator;

public class FileExample {
	
	public static void main(String[] args){
		CloudSchedSIM.init("FileExample");
		
		HomegeneousCluster homeCluster = new HomegeneousCluster(10, 1000, 4, 4000, 1000, 200000);
		BalanceStorer storer = new BalanceStorer();
		FileSystem fileSystem = new FileSystem(homeCluster, storer);
		FileSystemGenerator fileSystemGen = new FileSystemGenerator(100, 300, 100, 10);
		fileSystemGen.generate(fileSystem, storer);
		
		ResManager monolithicRM = new GeneralShareStateRM("Monolithic", homeCluster);
		UserBroker userBroker1 = new UserBroker("UserBroker1", SIMTag.RM_MODE_S);
		ResourceScaler resourceScaler = new ThresholdScaler(5, 0.5);
		SlotType slotType = new SlotType(1, 1000, 250, 0);
		WorkloadGenerator wlGen = new BatchWLfromFileGen(fileSystem, 100, 50, slotType);
		Workload wl = wlGen.generate(0);
		userBroker1.init(new AFCFSScheduler("FCFS-Gang"), resourceScaler);
		User user = new User("user", wl);
		userBroker1.addUser(user);
		CloudSchedSIM.addRM(monolithicRM);
		CloudSchedSIM.addUserBroker(userBroker1);
		CloudSchedSIM.startSimulation();
				
	}

}
